Question 1

What keyword/s would you use to identify patients who have hypertension listed in their discharge summary? If you would use multiple keywords or a regular expression, only enter one word here in all lower case!


Question 2

What keyword/s would you use to extract blood pressure measurements listed in discharge summaries?


Question 3

For the goal of identifying which patients have hypertension what initial window size would you select?


Question 4

For the goal of extracting any blood pressure measurements mentioned in the discharge summary - what initial window size would you select?


Question 5

For the goal of identifying which patients have hypertension which search approach would you use?


Question 6

For the goal of extracting any blood pressure measurements mentioned in the discharge summary which search approach would you use?


Question 7

Extract keyword windows from the discharge summaries that match the keyword "hypertension". How many notes have at least one hypertension window?


Question 8

Extract keyword windows from the discharge summaries that match the keyword "blood pressure". How many notes have at least one blood pressure window?

IMPORTANT INFORMATION!

If you started this problem on your own before checking out this quiz, you either: 1) concluded there are no windows that include the phrase "blood pressure" or 2) realized that the way we approached creating text windows doesn't allow for multi-word phrases. Oops.

Because this course is really about understanding the technique and less about proscribing how you solve the problem in R - I made a new extract_text_window function that can work with two keywords. It will start the window at the first matching word, then look at the next row's keyword using the "lead()" function. If it matches it keeps the window and extends out the WINDOW_END value by one word. Here is the new function that you can use!

extract_2words_text_window <- function(dataframe, keyword1, keyword2, half_window_size){
  dataframe %>% 
    group_by(NOTE_ID) %>% 
    mutate(WORDS = TEXT) %>% 
    separate_rows(WORDS, sep = "[ \n] ") %>% 
    mutate(INDEX = seq(from = 1, to = n(), by = 1.0),
           WINDOW_START = case_when(INDEX - half_window_size < 1 ~ 1,
                                    TRUE ~ INDEX - half_window_size),
           WINDOW_END = case_when(INDEX   half_window_size > max(INDEX) ~ max(INDEX),
                                  TRUE ~ INDEX   half_window_size),
           WINDOW = word(string = TEXT, start = WINDOW_START, end = WINDOW_END, sep = "[ \n] ")) %>% 
    ungroup() %>% 
    filter(str_detect(string = WORDS, pattern = regex(keyword1, ignore_case = TRUE)),
           str_detect(string = lead(WORDS), pattern = regex(keyword2, ignore_case = TRUE))) %>%
    mutate(WINDOW_END = WINDOW_END   1)
}

Question 9

Extract keyword windows from the discharge summaries that match the keyword "hypertension". How many keyword windows did you find?


Question 10

Extract keyword windows from the discharge summaries that match the keyword "blood pressure". How many windows are there that have the keyword "blood pressure"?

IMPORTANT INFORMATION!

If you started this problem on your own before checking out this quiz, you either: 1) concluded there are no windows that include the phrase "blood pressure" or 2) realized that the way we approached creating text windows doesn't allow for multi-word phrases. Oops.

Because this course is really about understanding the technique and less about proscribing how you solve the problem in R - I made a new extract_text_window function that can work with two keywords. It will start the window at the first matching word, then look at the next row's keyword using the "lead()" function. If it matches it keeps the window and extends out the WINDOW_END value by one word. Here is the new function that you can use!

extract_2words_text_window <- function(dataframe, keyword1, keyword2, half_window_size){
  dataframe %>% 
    group_by(NOTE_ID) %>% 
    mutate(WORDS = TEXT) %>% 
    separate_rows(WORDS, sep = "[ \n] ") %>% 
    mutate(INDEX = seq(from = 1, to = n(), by = 1.0),
           WINDOW_START = case_when(INDEX - half_window_size < 1 ~ 1,
                                    TRUE ~ INDEX - half_window_size),
           WINDOW_END = case_when(INDEX   half_window_size > max(INDEX) ~ max(INDEX),
                                  TRUE ~ INDEX   half_window_size),
           WINDOW = word(string = TEXT, start = WINDOW_START, end = WINDOW_END, sep = "[ \n] ")) %>% 
    ungroup() %>% 
    filter(str_detect(string = WORDS, pattern = regex(keyword1, ignore_case = TRUE)),
           str_detect(string = lead(WORDS), pattern = regex(keyword2, ignore_case = TRUE))) %>%
    mutate(WINDOW_END = WINDOW_END   1)
}

Question 11

How many discharge summaries had hypertension windows that were negated?


Question 12

Using the radiology reports - how many notes identified a kidney cyst?

Note: if the report mentions "upper pole", "mid pole", etc. these are all referencing the kidney. This is one of those cases where having some medical/domain expertise is helpful!


Question 13

Using the discharge summaries, extract all blood pressure measurements listed. How many windows had extractable systolic and diastolic blood pressure measurements?